package org.hot100_3;

public class leetcode11 {
    public int maxArea(int[] height) {

        int maxArea = 0;

        int n = height.length;

        int left = 0;
        int right = n - 1;
        int area = 0;

        while (left < right) {
            area = (right - left) * (Math.min(height[left], height[right]));
            maxArea = Math.max(maxArea, area);

            if (height[left] > height[right]) {
                right--;
            } else {
                left++;
            }
        }

        return maxArea;
    }
}
